<template>
  <div>
    <CourseList title="我的收藏" :courses="courses"/>
  </div>
</template>

<script>
import CourseList from '~/components/CourseList.vue'

export default {
  middleware: 'auth',
  components: {CourseList},
  async asyncData({$axios, error}) {
    try {
      const res = await $axios.$get('actions/lists', {
        params: {
          query: {
            populate: {path: 'object', populate: 'categories'},
            where: {type: 'Course', name: 'collect'},
          },
        },
      })
      return {
        courses: res.data,
      }
    } catch (err) {
      error({
        statusCode: 403,
      })
    }
  },
}
</script>

<style scoped lang="scss"></style>
